package com.example.h1nson.realphotography.asyncTask;

import android.os.AsyncTask;

import com.example.h1nson.realphotography.config.ConfigURL;
import com.example.h1nson.realphotography.interface_photo.OnDataFinishedListener;
import com.example.h1nson.realphotography.util.HttpClientPost;

import org.json.JSONObject;

/**
 * Created by H1nson on 2016/5/23.
 */
public class HttpAsynTask extends AsyncTask<String, Integer, String>{
    private OnDataFinishedListener onDataFinishedListener;
    private JSONObject jsonReq;
    private String URL;
    public HttpAsynTask(JSONObject jsonObject,String URL){
        this.jsonReq = jsonObject;
        this.URL = URL;
    }
    @Override
    protected String doInBackground(String... params) {
        String  jsonStr = jsonReq.toString();
        HttpClientPost post = new HttpClientPost(URL,jsonStr);
        post.doPost();
        return post.getJsonStrRes();
    }
    public void setOnDataFinishedListener(OnDataFinishedListener onDataFinishedListener){
        this.onDataFinishedListener = onDataFinishedListener;
    }
}
